Conversation
table/table.go
Outdated
| // We can't get the rows and headers from the table, so the user needs to | ||
| // provide them as arguments. | ||
| m.rows = rows | ||
| m.headers = headers |
There was a problem hiding this comment.
FYI: I wrote a helper function on lipgloss to convert the internal Data into a [][]string:
To avoid having to ask for the data again here, I think we should have a GetHeaders() and GetData() functions on lipgloss.
There is a small decision to make here. I'm not sure if GetData() should return a [][]string directly. For me, it makes more sense to make it return the internal table.Data interface and expose dataToMatrix as a public function.
There was a problem hiding this comment.
I agree, I think it makes more sense to only store the data once instead of managing the same set of values in two places (Model and lipgloss Table).
I vote that we add GetData() that returns a Data then the user can call DataToMatrix. Performance-wise it would be the same as we would probably be doing that type conversion under the hood if we were returning [][]string. This might lead users to want to include non-string values in the table... Is that something we want to support? I guess that feature could sit in the backlog for a bit while we think about it.
|
It seems to be working well in my tests 👏 Let me know if you have specific scenarios that you want help testing. |
|
We still need to get the number of rows and/or border heights + if it has headers to be able to jump around the content with Home/End keys and PageUp/PageDown keys. @andreynering |
table/table.go
Outdated
| // TODO make this not hard coded? | ||
| height := lipgloss.Height(table) - 6 |
There was a problem hiding this comment.
Note to self: take a look at this
Also, keeps any previously set data on the Lip Gloss table, if set.
|
What's the progress on this? Tested it out briefly, and a bit of feedback so far:
https://cdn.liam.sh/share/2025/07/explorer_80HMdm4hK2.mp4 there also seems to be a panic under certain scenarios (note, trace shows my fork, where all I did was merge v2-table onto current v2-exp branch, and create a tag, nothing custom): |
uses Lip Gloss table to render the table. Also allows users to create bubbles tables from existing Lip Gloss tables.
Bash notes
github.com/charmbracelet/bubbles/table
incompatible changes
removed: FromValues -> seems unnecessary
Allow chaining setters
New -> changed from func(...Option) Model to func(...Option) *Model
(*Model).SetCursor: changed from func(int) to func(int) *Model
(*Model).SetHeight: changed from func(int) to func(int) *Model
(*Model).SetRows: changed from func([]Row) to func(...[]string) *Model
(*Model).SetStyles: changed from func(Styles) to func(Styles) *Model
(*Model).SetWidth: changed from func(int) to func(int) *Model
Height and Width calculations now delegated to Lip Gloss
removed: Model.Width
removed: Model.Height
Removed wrapper types
ColumnandRowRowremoved: Row -> using [][]string instead
refactor: WithRows -> changed from func([]Row) Option to func(...[]string) Option
refactor: Model.Rows -> changed from func() []Row to func() [][]string
refactor: Model.SelectedRow -> changed from func() Row to func() []string
Columns, now headersrefactor: WithColumns() -> WithHeaders()
refactor: Model.Columns -> Model.Headers
refactor: (*Model).SetColumns -> (*Model).SetHeaders
removed: Column
Removed
viewportremoved: (*Model).UpdateViewport
compatible changes
Support Lip Gloss Border customizations
(*Model).Border: added
(*Model).BorderBottom: added
(*Model).BorderColumn: added
(*Model).BorderHeader: added
(*Model).BorderLeft: added
(*Model).BorderRight: added
(*Model).BorderRow: added
(*Model).BorderStyle: added
(*Model).BorderTop: added
(*Model).SetBorder: added
Manage styles
(*Model).OverwriteStyles: added
(*Model).OverwriteStylesFromLipgloss: added
(*Model).SetStyleFunc: added
(*Model).SetYOffset: added
NewFromTemplate: added
WithStyleFunc: added
Andrey's TODO:
pageup/pagedown/home/endwork correctly